package com.yxdj.user.service.impl;

import com.yxdj.common.redis.service.RedisService;
import com.yxdj.user.service.SMSService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
public class SMSServiceImpl implements SMSService {

    @Autowired
    private RedisService redisService;

    @Override
    public void sendCode(String phone) {
        //生成6位的随机字符串作为验证码
//        String code = RandomStringUtils.randomNumeric(6);
        //使用SMSUtils工具类向手机发送手机验证码
//        SMSUtils.sendCode(phone, code);
//        System.out.println("code = " + code);
        //将验证码保存到Redis中，并设置有效时间位5分钟
        redisService.setCacheObject("app:user:"+phone,"888888",5L, TimeUnit.MINUTES);
    }
}
